/*
 CREATE SEQUENCE seq_board_no 
 INCREMENT BY 1 
 START WITH 1 
;
CREATE SEQUENCE seq_category_no 
 INCREMENT BY 1 
 START WITH 1 
;
CREATE SEQUENCE seq_menu_no 
 INCREMENT BY 1 
 START WITH 1 
;
CREATE SEQUENCE seq_study_no 
 INCREMENT BY 1 
 START WITH 1 
;
CREATE SEQUENCE seq_title_no 
 INCREMENT BY 1 
 START WITH 1 
;

select * from member;

update member set g_no=3 where m_id='jobs'

DROP SEQUENCE seq_board_no;

DROP SEQUENCE seq_study_no;

select * from tab;


CREATE TABLE board (
       b_no                 INTEGER NOT NULL,
       b_subject            VARCHAR2(50) NOT NULL,
       b_content            VARCHAR2(4000) NOT NULL,
       b_writer             VARCHAR2(30) NOT NULL,
       b_writedate          DATE NOT NULL,
       b_readhit            INTEGER NOT NULL,
       b_ip                 VARCHAR2(50) NOT NULL,
       b_filename           VARCHAR2(200) NOT NULL,
       b_ref                INTEGER NOT NULL,
       b_step               INTEGER NOT NULL,
       b_depth				INTEGER NOT NULL,
       b_reply_count		INTEGER NOT NULL,		
       menu_no              INTEGER NOT NULL,
       cate_no              INTEGER NOT NULL,
       title_no             INTEGER NOT NULL
);

ALTER TABLE board
       ADD  ( PRIMARY KEY (b_no) ) ;

drop table board

CREATE TABLE category (
       cate_no              INTEGER NOT NULL,
       cate_name            VARCHAR2(30) NOT NULL,
       menu_no              INTEGER NOT NULL,
       cate_step            INTEGER NULL
);


ALTER TABLE category
       ADD  ( PRIMARY KEY (cate_no) ) ;


CREATE TABLE menu (
       menu_no              INTEGER NOT NULL,
       menu_name            VARCHAR2(30) NOT NULL,
       menu_step            INTEGER NULL
);


ALTER TABLE menu
       ADD  ( PRIMARY KEY (menu_no) ) ;


CREATE TABLE study (
       s_no             	INTEGER NOT NULL,
       s_subject              VARCHAR2(50) NOT NULL,
       s_content              VARCHAR2(4000) NOT NULL,
       s_writer               VARCHAR2(30) NOT NULL,
       s_writedate           DATE NOT NULL,
       s_filename             VARCHAR2(200) NULL,
       s_step        	    INTEGER NOT NULL,
       menu_no				INTEGER NOT NULL,
       title_no             INTEGER NOT NULL,
       cate_no              INTEGER NOT NULL
);


drop table study;


ALTER TABLE study
       ADD  ( PRIMARY KEY (s_no) ) ;


CREATE TABLE title (
       title_no             INTEGER NOT NULL,
       title_name           VARCHAR2(30) NOT NULL,
       cate_no              INTEGER NOT NULL,
       title_step           INTEGER NULL
);



ALTER TABLE title
       ADD  ( PRIMARY KEY (title_no) ) ;


ALTER TABLE board
       ADD  ( FOREIGN KEY (title_no)
                             REFERENCES title ) ;


ALTER TABLE board
       ADD  ( FOREIGN KEY (cate_no)
                             REFERENCES category ) ;


ALTER TABLE board
       ADD  ( FOREIGN KEY (menu_no)
                             REFERENCES menu ) ;


ALTER TABLE category
       ADD  ( FOREIGN KEY (menu_no)
                             REFERENCES menu ) ;


ALTER TABLE study
       ADD  ( FOREIGN KEY (cate_no)
                             REFERENCES category ) ;

ALTER TABLE study
       ADD  ( FOREIGN KEY (title_no)
                             REFERENCES title ) ;

ALTER TABLE study
       ADD  ( FOREIGN KEY (menu_no)
                             REFERENCES menu ) ;



ALTER TABLE title
       ADD  ( FOREIGN KEY (cate_no)
                             REFERENCES category ) ;


--������ �߰�--
--menu--
insert into menu values(
			seq_menu_no.nextVal,
			'STUDY', seq_menu_no.currVal);

insert into menu values(
			seq_menu_no.nextVal,
			'COMMUNITY', seq_menu_no.currVal);						
update menu set menu_name='STUDY' where menu_name='COMMUNITY'
			
select * from menu;	
		
--category--
insert into category values(seq_category_no.nextVal,'Java Programing',1,seq_category_no.currVal);
insert into category values(seq_category_no.nextVal,'Web Programing',1,seq_category_no.currVal);
insert into category values(seq_category_no.nextVal,'Mobile Programing',1,seq_category_no.currVal);


insert into category values(seq_category_no.nextVal,'��ü �Խ���',2,seq_category_no.currVal);
insert into category values(seq_category_no.nextVal,'���� �Խ���',2,seq_category_no.currVal);
insert into category values(seq_category_no.nextVal,'���� �Խ���',2,seq_category_no.currVal);
insert into category values(seq_category_no.nextVal,'�׷� �Խ���',2,seq_category_no.currVal);

--title--
insert into title values(seq_title_no.nextVal,'����',5,seq_title_no.currVal);
insert into title values(seq_title_no.nextVal,'������',5,seq_title_no.currVal);
insert into title values(seq_title_no.nextVal,'���',5,seq_title_no.currVal);

insert into title values(0,'no_title',8,0)


select * from category order by cate_step asc

update category set cate_step=1 where cate_no=5;
update category set cate_step=2 where cate_no=6;
update category set cate_step=3 where cate_no=7;


update title set title_step=1 where title_no=1;
update title set title_step=2 where title_no=2;
update title set title_step=3 where title_no=3;
select * from title

select * from category
--test--
select * from category where menu_no = (select menu_no from menu where menu_name='STUDY')

select * from title where cate_no=5

select * from study
delete from study where subject='������?'

select * from category where menu_no=(select menu_no from menu where menu_name='COMMUNITY')

select * from title

insert into title values(seq_title_no.nextVal,'��⵵',10,0);
insert into title values(seq_title_no.nextVal,'��û��',10,0);
insert into title values(seq_title_no.nextVal,'���',10,0);
insert into title values(seq_title_no.nextVal,'���',10,0);
					 
   
 select * from board
 select min(cate_step) from category
 
insert into board values(
						seq_board_no.nextVal,
						'���',
						'�׽�Ʈ�� ���2�Դϴ�.',
						'����',
						sysdate,
						'no_pwd',
						0,
						'100.100.100',
						'no_file',
						1,
						2,
						2,
						8,
						0
						)
 update board set b_step=1 where b_no=61

 
 update board set b_content='dddd' where b_no=66
  
    
 select * from board where b_step>0
 delete from study
 select * from category where menu_no=1 order by cate_step asc
 
 
 
 
 
 
 */